< previous page page_55 next page >

Page 55
is the default. But even with these border styles, you can individually control whether these elements appear on the form. The ControlBox, MaxButton, and MinButton properties each have a True or False setting that determines whether the particular element appears on the form. The default setting for each of these properties is True. If you set a property to False, the corresponding element is not displayed on the form. These properties can be changed only at design time.
The Font property lets you set the base font and font characteristics for any text displayed directly on the form by using the form's Print method.
note.gif The Font property of a form is actually an object itself with its own properties. For example, to change the size of a form's font, you enter Form1.Font.Size = 10 in a Code window (or the Immediate window, for that matter) to change the size to 10 points. square.gif

In addition, setting the form's Font property sets the font for all controls subsequently added to the form.
One final form property of note is the StartupPosition property. As you might guess, this property controls where the form is located when it is first displayed. The StartupPosition property has four possible settings, which are summarized in Table 3.4.
Table 3.4 StartupPosition Property Settings
SettingEffect
0 - ManualThe initial position is set by the Top and Left properties of the form.
1 - CenterOwnerThe form is centered in the Windows desktop unless it is an MDI child form, in which case it is centered within its parent window.
2 - CenterScreenThe form is centered in the Windows desktop.
3 - Windows DefaultThe form is placed in a position determined by Windows based on the number and position of other windows open at that time.

Although the StartupPosition property can center your form for you when the form first loads, it does not keep the form centered. For example, if you resize the form, it does not remain centered.
Displaying a Form
If you write a program with just a single form, you needn't worry about displaying the form or hiding it. This process is performed automatically for you as the program starts and exits. This single form is known as the Startup Object or Startup Form. When you run your program, Visual Basic loads your Startup Form into memory and displays it. As long as this form remains loaded, your program keeps running and responding to events. When you click the Close button on the form (or execute the End statement), the program stops.

 
< previous page page_55 next page >